def find(s, ch):
    return [i for i, ltr in enumerate(s) if ltr == ch]

def readgrid(fname):
	grid = []
	f = open(fname,'r')
	for l in f:
		start = 0
		line = []
		for pos in find(l,' '):
			line.append(int(l[start:pos]))
			start = pos+1
		line.append(int(l[pos+1:-1]))
		grid.append(line)
	return grid

largest = 0
grid = readgrid('grid')
rows = len(grid)
cols = len(grid[0])

for line in grid:
	for col in range(cols-4):
		product = line[col]*line[col+1]*line[col+2]*line[col+3]
		if product > largest:
			largest = product
			
for col in range(cols):
	for row in range(rows-4):
		product = grid[row][col]*grid[row+1][col]*grid[row+2][col]*grid[row+3][col]
		if product > largest:
			largest = product

for col in range(cols-4):
	for row in range(rows-4):
		product = grid[row][col+3]*grid[row+1][col+2]*grid[row+2][col+1]*grid[row+3][col]
		if product > largest:
			largest = product
			
for col in range(cols-4):
	for row in range(rows-4):
		product = grid[row][col]*grid[row+1][col+1]*grid[row+2][col+2]*grid[row+3][col+3]
		if product > largest:
			largest = product
			
print(largest)